<template>
  <div class="contain">
    <img
      src="http://124.223.73.204:8080/img/profile/bg.png"
      alt=""
      class="beijing"
    />
    <div class="denglu">
      <div class="Loginbox">

        <img :src="('http://www.xiaoshuaipeng.com:8080' + obj.avatar)" alt=""  v-if="obj.avatar"/>
        <img src="http://124.223.73.204:8080/img/profile/avatar.png" alt="" v-else>
      </div>
      <div class="username">{{ obj.nickname }}</div>
      <div>
        <router-link to="/login" v-if="!token">去登录</router-link>
        <button v-else @click="tuic">退出登录</button>
      </div>
    </div>
    <div class="goneng">
      <div class="gonengbox">
        <div class="hezi">
          <van-icon name="star-o" size="20" />
          <p>我的收藏</p>
        </div>
      </div>
      <div class="gonengbox">
        <div class="hezi">
          <van-icon name="wap-home-o" size="20" />
          <p>我的出租</p>
        </div>
      </div>
      <div class="gonengbox">
        <div class="hezi">
          <van-icon name="clock-o" size="20" />
          <p>看房记录</p>
        </div>
      </div>
      <div class="gonengbox">
        <div class="hezi">
          <van-icon name="idcard" size="20" />
          <p>成为房主</p>
        </div>
      </div>
      <div class="gonengbox">
        <div class="hezi">
          <van-icon name="contact" size="20" />
          <p>个人资料</p>
        </div>
      </div>
      <div class="gonengbox">
        <div class="hezi">
          <van-icon name="service-o" size="20" />
          <p>联系我们</p>
        </div>
      </div>
    </div>
    <div class="tupian">
      <img
        src="http://124.223.73.204:8080/img/profile/join.png"
        alt=""
        class="guanggao"
      />
    </div>
  </div>
</template>

<script>
import { delToken, getToken } from "@/utils/stronage";
import { index } from "@/api/user";
import { Dialog } from "vant";
export default {
  components:{
    [Dialog.name]:Dialog
  },
  data() {
    return {
      obj: {},
      token: "",
    };
  },
  async created() {
    this.token = getToken();
    // console.log(token)
    const res = await index(this.token);
    this.obj = res.data.body;
    console.log(res);
  },
  methods:{
    tuic(){
      Dialog.confirm({
        title:'确认退出登录',
        message:'退出登录'
      }).then(()=>{
          this.$router.push('/')
          delToken()

      })

    },

  }
};
</script>

<style lang="less" scoped>
.contain {
  background-color: #fff;
  height: 100%;
  .beijing {
    position: fixed;
    top: 0;
    left: 0;
    width: 375px;
    height: 191px;
  }
  .denglu {
    box-sizing: border-box;
    position: absolute;
    background: #fff;
    width: 319px;
    height: 165px;
    top: 21vw;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0px 0px 10px 3px #ddd;
    margin: 50px auto 0;
    padding: 0 20px;
    padding-top: 0;
    text-align: center;
    font-size: 13px;
    .Loginbox {
      position: relative;
      transform: translateY(-50%);
      border-radius: 50%;
      width: 70px;
      height: 70px;
      border: solid 5px #f5f5f5;
      display: inline-block;
      box-shadow: 0px 2px 2px #bdbdbd;
      img {
        width: 100%;
        border-radius: 50%;
        margin-top: 2px;
      }
    }
    .username {
      margin-top: -6vw;
      margin-bottom: 10px;
    }
    .dengluruko {
      font-size: 13px;
      height: 30px;
      line-height: 30px;
      padding: 0 15px;
    }
    a {
      display: block;
      position: relative;
      top: 3.33333vw;
      left: 37%;
      width: 39px;
      height: 30px;
      border: none;
      font-size: 13px;
      line-height: 30px;
      padding: 0 15px;
      border-radius: 5px;
      background-color: #21b97a;
      color: #fff;
    }
  }
  .goneng {
    position: relative;
    top: 80vw;
    display: flex;
    width: 100%;
    height: 190px;
    color: white;
    flex-wrap: wrap;
    .gonengbox {
      width: 33.333%;
      height: 65px;
      padding: 15px 0;
      .hezi {
        width: 100%;
        height: 45px;
        margin: 10px 0;
        i {
          display: block;
          text-align: center;
          margin-bottom: 10px;
          color: #333;
        }
        p {
          margin: 0;
          font-size: 13px;
          color: #333;
          text-align: center;
        }
      }
    }
  }
  .tupian {
    position: absolute;
    bottom: 20vw;
    width: 100%;
    height: 85px;
    text-align: center;
    img {
      width: 92%;
      height: 100%;
    }
  }
}
</style>
